﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using KeZhou.Models.Instances;
using KeZhou.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;

namespace KeZhou.ViewModels
{
    internal partial class MainSkeletonViewModel : ObservableObject
    {
        private static MainSkeletonViewModel instance;
        public static MainSkeletonViewModel Instance
        {
            get
            {
                return instance ?? (instance = new MainSkeletonViewModel());
            }
        }

        //当前的模式 0-使用指南 1-选择城市 2-旅行资讯 3-我的想去 4-旅行方案 6-我的账号
        [ObservableProperty]
        private int currentMode = 0;

        //隐藏或者展开窗口
        [ObservableProperty]
        private bool isHiddingAi = true;
        [ObservableProperty]
        private bool isShowingAi = false;

        //改变TabBar
        [RelayCommand]
        public void changeMode(int newMode)
        {
            if (newMode != CurrentMode)
            {
                string cityName = PlanOnBuilding.Instance.cityName;
                if (newMode >=2 && newMode <=3 && string.IsNullOrEmpty(cityName))
                {
                    AppDetailView.Instance.showMyMsg("请先选择城市和时间");
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        switch (newMode)
                        {
                            case 0:
                                AppDetailView.Instance.OnSwitchControl(ControlType.MainOne);
                                break;
                            case 1:
                                AppDetailView.Instance.OnSwitchControl(ControlType.MainTwo);
                                break;
                            case 2:
                                AppDetailView.Instance.OnSwitchControl(ControlType.MainThree);
                                break;
                            case 3:
                                AppDetailView.Instance.OnSwitchControl(ControlType.MainFour);
                                break;
                            case 4:
                                AppDetailView.Instance.OnSwitchControl(ControlType.MainFive);
                                break;
                            case 6:
                                AppDetailView.Instance.OnSwitchControl(ControlType.MainSix);
                                break;
                        }
                    });
                    CurrentMode = newMode;

                }
            }
        }

        //展开和收起AI面板
        [RelayCommand]
        private void openAi()
        {
            IsHiddingAi = false;
            IsShowingAi = true;
            AppDetailView.Instance.openAi();
        }

        [RelayCommand]
        private void hideAi()
        {
            IsHiddingAi = true;
            IsShowingAi = false;
            AppDetailView.Instance.closeAi();
        }
    }
}
